using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class PeriodMap : EntityTypeConfiguration<Period>
    {
        public PeriodMap()
        {
            // Primary Key
            this.HasKey(t => t.PERIOD1);

            // Properties
            this.Property(t => t.PERIOD1)
                .IsRequired()
                .HasMaxLength(4);

            this.Property(t => t.CLOSED)
                .HasMaxLength(1);

            this.Property(t => t.REALPERIOD)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Periods");
            this.Property(t => t.PERIOD1).HasColumnName("PERIOD");
            this.Property(t => t.START).HasColumnName("START");
            this.Property(t => t.END).HasColumnName("END");
            this.Property(t => t.CLOSED).HasColumnName("CLOSED");
            this.Property(t => t.REALPERIOD).HasColumnName("REALPERIOD");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
        }
    }
}
